#ifndef TRANSIVER_H
#define TRANSIVER_H
#include<QTcpSocket>
#include<QJsonObject>
#include<QJsonDocument>
#include<QObject>
//收发器类，用于服务器与客户端间的通信与解析
class Transiver : public QObject
{
    Q_OBJECT
private:
    //客户端
    QString username;
    QTcpSocket *socket;
    int select;
public:
    Transiver(QString username, QTcpSocket* socket, int select);
    ~Transiver();
    void sendMsg(int xpos, int ypos, QString type);
    void sendMsg(QString msg);
    void sendMsg(int select);

    void parse(QByteArray jsonBytes);

public slots:
    void sendStopMsg();


signals:
    void broadCast(int select, int xpos, int ypos, QString type);
    void broadCast(QString username, QString msg);
    void broadCast(int select, QString username);
    void GameStart();
    void GameStop();
};

#endif // TRANSIVER_H
